
SWEP.Author				= ''
SWEP.Contact			= ''
SWEP.Purpose			= ''
SWEP.Instructions		= ''

SWEP.ViewModel			= 'models/weapons/v_toolgun.mdl'
SWEP.WorldModel			= 'models/weapons/w_toolgun.mdl'
SWEP.AnimPrefix			= 'python'



util.PrecacheModel(SWEP.ViewModel)
util.PrecacheModel(SWEP.WorldModel)

SWEP.ShootSound			= Sound('Airboat.FireGunRevDown')

SWEP.Primary =
{
	ClipSize 	= -1,
	DefaultClip = -1,
	Automatic = false,
	Ammo = 'none'
}

SWEP.Secondary =
{
	ClipSize 	= -1,
	DefaultClip = -1,
	Automatic = false,
	Ammo = 'none'
}

SWEP.CanHolster			= true
SWEP.CanDeploy			= true


function SWEP:Initialize()
end


function SWEP:OnRestore()
end

function SWEP:Precache()
	util.PrecacheSound(self.ShootSound)
end

function SWEP:Reload()
	if (!self.Owner:KeyPressed(IN_RELOAD)) then return end
end

function SWEP:Think()
end

function SWEP:DoShootEffect(hitpos, hitnormal, entity, physbone)
	self.Weapon:EmitSound(self.ShootSound)
	self.Weapon:SendWeaponAnim(ACT_VM_PRIMARYATTACK) 	-- View model animation

	-- There's a bug with the model that's causing a muzzle to
	-- appear on everyone's screen when we fire this animation.
	--self.Owner:SetAnimation(PLAYER_ATTACK1)			-- 3rd Person Animation

	local effectdata = EffectData()
	effectdata:SetOrigin(hitpos)
	effectdata:SetNormal(hitnormal)
	effectdata:SetEntity(entity)
	effectdata:SetAttachment(physbone)
	util.Effect('selection_indicator', effectdata)

	local effectdata = EffectData()
	effectdata:SetOrigin(hitpos)
	effectdata:SetStart(self.Owner:GetShootPos())
	effectdata:SetAttachment(1)
	effectdata:SetEntity(self.Weapon)
	util.Effect('ToolTracer', effectdata)
end

function SWEP:PrimaryAttack()
	local tr = util.GetPlayerTrace(self.Owner)
	tr.mask = (CONTENTS_SOLID|CONTENTS_MOVEABLE|CONTENTS_MONSTER|CONTENTS_WINDOW|CONTENTS_DEBRIS|CONTENTS_GRATE|CONTENTS_AUX)
	local trace = util.TraceLine(tr)
	if (!trace.Hit) then return end

	self:DoShootEffect(trace.HitPos, trace.HitNormal, trace.Entity, trace.PhysicsBone)
end

function SWEP:SecondaryAttack()
	local tr = util.GetPlayerTrace(self.Owner)
	tr.mask = (CONTENTS_SOLID|CONTENTS_MOVEABLE|CONTENTS_MONSTER|CONTENTS_WINDOW|CONTENTS_DEBRIS|CONTENTS_GRATE|CONTENTS_AUX)
	local trace = util.TraceLine(tr)
	if (!trace.Hit) then return end

	self:DoShootEffect(trace.HitPos, trace.HitNormal, trace.Entity, trace.PhysicsBone)
end

function SWEP:ContextScreenClick(aimvec, mousecode, pressed, ply)
	if (!pressed) then return end

	-- No prediction in single player
	if (CLIENT && SinglePlayer()) then return end

	local ViewEnt = ply

	if (CLIENT) then ViewEnt = GetViewEntity() end
	if (SERVER) then ViewEnt = ply:GetViewEntity() end

	local tr = utilx.GetPlayerTrace(ViewEnt, aimvec)
	local trace = util.TraceLine(tr)
	if (!trace.Hit) then return end

	if (mousecode == MOUSE_LEFT) then
	else
	end

	self:DoShootEffect(trace.HitPos, trace.HitNormal, trace.Entity, trace.PhysicsBone)
end

function SWEP:Holster()
	return true
end

function SWEP:OnRemove()
end

function SWEP:OwnerChanged()
end

function SWEP:Deploy()
	return true
end
